Repository navigation
Inkling 2 Mini DSpark on Metal: the block attends on the M5 tensor units, so a hold stays near flat in context (10.55 to 5.63 ms at 128K) - #4660
Conversation
aefb063 to
c41911e
Compare
|
Sorry for the noise: this was closed automatically when #4387 landed on main and its base branch was removed. It is reopened and now targets
|
|
I can run this one on an M5 Max as well, alongside #4631: Apple M5 Max (40-core GPU), 128 GB, macOS build 26B131, Zig 0.17.0. Plan: Same question as on #4631: |
|
@Spectre056 thank you. The same answer as on #4631, with one difference. The base is moving (#4387 is on The difference: this PR changes only the drafter. The target verifies every draft, and on the full stack 24 of 24 greedy replies were identical with the drafter's attention on the tensor units, on its scalar kernel and with no drafter (accepted drafts 4,021 of 9,498 against 4,013 of 9,112). So replies do not move here; what the tensor-unit sums change is the drafter's own arithmetic. Whether that passes the bit-equality rule from #4448 is the maintainers' call and has not been said yet. Once there is a head on |
|
Understood, thanks for the detail on the drafter. I'll wait for the head on |
28a0b46 to
cf447cc
Compare
|
@sethforprivacy, the rebase onto The other 14 commits on the branch are dropped, because
What's left is the change only this PR makes: splitting the M5 DSpark block attention across context chunks and folding their partials. Main's attention has changed a lot since 22 Nov, so we'll review it fresh on this head. Then we'll run the M5 checks against
|
|
Thanks @sethforprivacy. #4660 is one commit, Exactness
Asks
Tests
Repo checks we ran on this branch:
The M5 check we'd like to see, main against this branch:
|
|
Thanks, @ashhart. Both asks make sense:
|
|
Pushing the re-cut head now: |
cf447cc to
41b31ae
Compare
|
New head Admission: Repo checks (M5 Ultra, Inkling 2 Mini checkpoint present, a fresh test binary):
The M5 runs below were on M5 served, Tokens: equal ids, sha and top logprobs in all 40 rows, 20 greedy and 20 sampled. Acceptance (accepted / drafted, from the server's per-request lines), main → branch:
Hold time (the drafter's attention per round, median ms, from a local timing patch that isn't on the branch), main → branch:
Drafted decode, one stream (tok/s), main → branch: greedy 42.1 → 41.4 (1K), 49.9 → 49.3 (8K), 21.0 → 21.4 (32K), 57.8 → 59.1 (128K); sampled 33.5 → 33.1, 33.4 → 33.6, 19.1 → 19.3, 45.5 → 46.6. With four streams, each stream's rate mostly measures its wait behind the others' prompts, so I'm not comparing those. So the hold is close to flat in context now (one stream: 4.0 to 5.6 ms from 1K to 128K, against 4.1 to 10.6 on Not covered: a Mac without tensor units. That row is the admission test plus the fallback to |
|
Thanks for the admission fix and the re-cut, which close both review asks. Decision: waiting on the M5 cells the review named, which are ours: we've queued them on our M5 Ultra - drafted tokens per second and acceptance at 1K, 8K, 32K and 128K with one stream and four holding at once, greedy and sampled, the hold time against context length, and the same greedy tokens as main at each length. Your posted table covers much of it (the hold close to flat in context). What stands: the block attends on the tensor units a chunk a threadgroup, a hold takes 3.4 to 3.6 ms at any context, and the admission fix makes Main's DSpark block attention scores every kept key on scalar threads; the units kernels are not on main.
|
Synthena Initial Review — Performance receipt required (
|
… of its context a threadgroup, so a hold costs the same at any context
…only where it holds one, so a Mac without tensor units admits what main does
…rnel in every build, not only past a debug assert
…park-units: tokens equal main's
|
A new head is coming, |
41b31ae to
9abef9e
Compare
|
New head
The M5 checks, comparing main with this head:
About the receipt gate. I ran
There's also a catch in the CI step: it checks the receipt's How do you want a claim that isn't about decode speed receipted? I can re-run with a pack you name, or the PR can carry whatever label skips the speed floor. Or, if this PR shouldn't carry |
Synthena Initial Review — Needs changes (
|
|
@sethforprivacy thanks for the re-cut. A read of the current head found no problems in the kernels, the store or the admission charge, so the only thing between this and a landing train is the That check reads the committed receipt, and it fails on the receipt's own numbers. The receipt measured short prompts, where the PR says decode stays at main's rate: the mean is -0.40% and neither ABBA pair beats base, so it cannot clear the 0.50% floor. The gain this PR claims lives at long context (the hold falling from 10.55 to 5.63 ms at 128K), and no cell in the receipt measures it. Could you record the receipt at the context where the claim is, for example drafted decode with a 64K or 128K prompt, same ABBA order and checkpoint, on the current head? The stale-head error from 3 Dec clears on its own: the checker on main now accepts a head whose only commits after the measured one touch
|
…park-units at 128K: drafted decode +6.7%, tokens equal main's
|
Done: new head
The pack is committed next to the receipt as One catch: CI's |
|
Thanks @sethforprivacy. The admission charge and release-capacity guard close the earlier asks. The new long-context receipt supplies the requested workload and records matching outputs with a 6.7% drafted-decode gain. We will wire its approved pack into both verification stages while preserving the strict gates. No further receipt rerun is needed for the documentation-only head.
|
What this changes
Before: a DSpark block's attention scores every kept key of its context on scalar threads, so a drafter's hold grows with the context. With one stream, main's median hold is 4.08 ms at 1K and 10.55 ms at 128K.
After, where the GPU has tensor units: the block attends on the tensor units, a chunk of its context a threadgroup, and the median hold is 4.04 ms at 1K and 5.63 ms at 128K. Replies are token-for-token the same as main's. Without tensor units the block takes main's kernel, and admission charges what main does.
This is a re-cut onto main. The drafter is opt-in (
--drafter), and only the drafter's own sums change.0ca167746. Commits:da7c050bc(the kernels),75e2d5159(admission charges the units' store only where it is held),232fbfa2e(the capacity check runs in every build),9abef9e21(short-prompt receipt),9f106c814(128K receipt and its pack).The two kernels (
dspark_units.metal, loaded only where the GPU has tensor units):tf_ink2_dspark_attn_units: a threadgroup is one key head and one chunk of 256 kept keys. Scores and weighted values are tensor products over 64-key tiles read from the context ring, with a running peak and mass a (row, head) pair. It writes a partial a pair and chunk.tf_ink2_dspark_attn_merge: a threadgroup is one (row, head). It scores the block's own eight keys first, then folds the chunks' partials in order and rounds once to BF16. Because the block's keys come first,ll >= 1before any chunk, so an empty chunk adds nothing and there is no0 / 0.All three drafter layers take them: the two sliding layers over their last 1,024 keys and the global layer over everything kept.
The store. The partials live in a store the drafter holds (
dspark_units.zig), sized from the context capacity.scoreBytescharges it only whereState.held()is true, so a Mac without tensor units admits what main does; the native opener andadmit.demandAtpass that through.attendchecks every stream's span against the store in every build, and a context past it takes main's kernel instead of writing past the store.Which bits change. Only the drafter's: a weight is rounded to BF16 before it multiplies a value, as the target's prompt attention does, and the sums run a tile at a time instead of in key order. A draft is a proposal the target verifies, so no reply changes. What can move is how many drafts land, and acceptance stays within about 2 points of main's everywhere below.
Checks on this head
9f106c814. The code is232fbfa2e's; the two commits after it touch onlydocs/receipts/.0ca167746with the same script:tf-kernel-contract: the units' contract entries (metal_inkling2_dspark_units.zig, checked against a float64 softmax within a stated bound, with planted controls) build. The contract run aborts (134) on main too.dspark_kernels_test.zig); the store's bound at tile edges up to 1,048,576 tokens (dspark_units.zig); admission at fixed budgets with and without the store (inkling2_admit_test.zig).zig build native -Dcpu=apple_m1: compiles.zig fmt --checkandgit diff --check: clean.zigpasses on this head.Receipt
docs/receipts/inkling2-mini-metal-dspark-units/perf-receipt.json, from main'stools/perf_receipt.py runon the M5 Ultra: main0ca167746against9abef9e21, drafter on, two ABBA pairs, the planted control,--check-draft. Its pack is committed beside it,pack-long-128k.json: two prompts, a greedy one and a seeded one, each 131,072 tokens of TensorFold's owndocs/**/*.mdat0ca167746, cut by the checkpoint's tokenizer, with 256 tokens out.verify --pack docs/receipts/inkling2-mini-metal-dspark-units/pack-long-128k.jsonpasses with the speed floor. CI'sverifychecks every receipt againsttools/receipt_prompts.json, so it reports a pack mismatch here.fcd43a42), with 1K to 128K prompts, one and four streams, greedy and sampled:Checklist